/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author freis
 */
@Entity
@Table(name = "contas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contas.findAll", query = "SELECT c FROM Contas c"),
    @NamedQuery(name = "Contas.findByIdContas", query = "SELECT c FROM Contas c WHERE c.idContas = :idContas"),
    @NamedQuery(name = "Contas.findByUsername", query = "SELECT c FROM Contas c WHERE c.username = :username"),
    @NamedQuery(name = "Contas.findByPassword", query = "SELECT c FROM Contas c WHERE c.password = :password")})
public class Contas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idContas")
    private Integer idContas;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "username")
    private String username;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "password")
    private String password;
    @JoinColumn(name = "Funcionarios_idFuncionario", referencedColumnName = "idFuncionario")
    @ManyToOne(optional = false)
    private Funcionarios funcionariosidFuncionario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contasidContas")
    private Collection<Sessoes> sessoesCollection;

    public Contas() {
    }

    public Contas(Integer idContas) {
        this.idContas = idContas;
    }

    public Contas(Integer idContas, String username, String password) {
        this.idContas = idContas;
        this.username = username;
        this.password = password;
    }

    public Integer getIdContas() {
        return idContas;
    }

    public void setIdContas(Integer idContas) {
        this.idContas = idContas;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Funcionarios getFuncionariosidFuncionario() {
        return funcionariosidFuncionario;
    }

    public void setFuncionariosidFuncionario(Funcionarios funcionariosidFuncionario) {
        this.funcionariosidFuncionario = funcionariosidFuncionario;
    }

    @XmlTransient
    public Collection<Sessoes> getSessoesCollection() {
        return sessoesCollection;
    }

    public void setSessoesCollection(Collection<Sessoes> sessoesCollection) {
        this.sessoesCollection = sessoesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idContas != null ? idContas.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contas)) {
            return false;
        }
        Contas other = (Contas) object;
        if ((this.idContas == null && other.idContas != null) || (this.idContas != null && !this.idContas.equals(other.idContas))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Contas[ idContas=" + idContas + " ]";
    }
    
}
